home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / s / scroller.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  3.1 KB  |  99 lines

  1. ; Resident program to provide flicker-free write_tty scroll for Color
  2.  
  3. ;  Graphics Adapter clones with dual-ported memory.  M. Abrash 5/3/86.
  4.  
  5. ; Make runnable with MASM-LINK-EXE2BIN.
  6.  
  7. cseg    segment
  8.  
  9.     assume    cs:cseg
  10.  
  11.     org    100h    ;necessary for COM file
  12.  
  13. start    proc    near
  14.  
  15.     jmp    makeres
  16.  
  17. old_int10    dd    ?
  18.  
  19. ; front end routine for BIOS video handler to scroll without flicker
  20.  
  21. scroll_front_end:
  22.  
  23.     cmp    ax,0e0ah    ;only intercept write_tty function
  24.  
  25.     jnz    pass_to_bios    ; called with linefeed
  26.  
  27.     push    ax
  28.  
  29.     push    bx
  30.  
  31.     mov    ah,0fh
  32.  
  33.     int    10h        ;get current page & mode
  34.  
  35.     cmp    al,2
  36.  
  37.     jz    check_row    ;BIOS only blanks in modes 2 & 3, so
  38.  
  39.     cmp    al,3        ; only intercept linefeed scroll in
  40.  
  41.     jnz    pass_to_bios2    ; modes 2 & 3
  42.  
  43. check_row:            ;see if cursor is on bottom row, in
  44.  
  45.     push    cx        ; which case linefeed causes scroll
  46.  
  47.     push    dx
  48.  
  49.     mov    ah,3
  50.  
  51.     int    10h        ;get cursor location in current page
  52.  
  53.     cmp    dh,24
  54.  
  55.     jnz    pass_to_bios3    ;cursor not on bottom row, no scroll
  56.  
  57.     push    ds        ;meets all the criteria, so perform
  58.  
  59.     push    es        ; scroll in current page with special
  60.  
  61.     push    si        ; routine that doesn't disable video
  62.  
  63.     push    di
  64.  
  65.     mov    ah,0fh
  66.  
  67.     int    10h        ;get # columns & page
  68.  
  69.     mov    al,ah
  70.  
  71.     sub    ah,ah    ;convert to word    
  72.  
  73.     push    ax    ;set aside # columns
  74.  
  75.     mov    si,ax
  76.  
  77.     shl    si,1    ;move from second row (each character=2 bytes)
  78.  
  79.     mov    ah,24
  80.  
  81.     mul    ah    ;# words to move (24 rows)
  82.  
  83.     mov    cx,ax
  84.  
  85.     sub    ax,ax    ;now adjust offsets for current page
  86.  
  87.     mov    ds,ax    ;buffer length is stored in BIOS segment
  88.  
  89.     mov    al,bh    ;get current page
  90.  
  91.     mul    word ptr ds:[44ch] ;offset of start of current page
  92.  
  93.     add    si,ax    ;move data from second row of current page
  94.  
  95.     mov    di,ax    ; to top of current page
  96.  
  97.     mov    ax,0b800h
  98.  
  99.     mov    ds,ax
  100.  
  101.     mov    es,ax        ;will move data in display segment
  102.  
  103.     cld
  104.  
  105.     rep movsw        ;scroll screen up
  106.  
  107.     mov    ah,8    ;BH already has current page
  108.  
  109.     int    10h    ;get attribute of character at cursor
  110.  
  111.     mov    al,' '    ;fill with blanks & attribute just obtained
  112.  
  113.     pop    cx    ;# of words per row
  114.  
  115.     rep    stosw        ;blank bottom row-DI points to bottom row
  116.  
  117.     pop    di    ;done
  118.  
  119.     pop    si
  120.  
  121.     pop    es
  122.  
  123.     pop    ds
  124.  
  125.     pop    dx
  126.  
  127.     pop    cx
  128.  
  129.     pop    bx
  130.  
  131.     pop    ax
  132.  
  133.     iret
  134.  
  135. pass_to_bios3:
  136.  
  137.     pop    dx
  138.  
  139.     pop    cx
  140.  
  141. pass_to_bios2:
  142.  
  143.     pop    bx
  144.  
  145.     pop    ax
  146.  
  147. pass_to_bios:        ;pass interrupt to normal BIOS handler
  148.  
  149.     jmp    cs:[old_int10]
  150.  
  151. endres:
  152.  
  153. ; make scroll front end handler resident & revector interrupt 10 to it
  154.  
  155. makeres:
  156.  
  157.     push    cs
  158.  
  159.     pop    ds
  160.  
  161.     assume    ds:cseg
  162.  
  163.     mov    ax,3510h    ;DOS get vector function, vector 10h
  164.  
  165.     int    21h        ;get vector 10h
  166.  
  167.     mov    word ptr [old_int10],bx    ;set aside old vector to
  168.  
  169.     mov    word ptr [old_int10+2],es    ; allow pass to BIOS
  170.  
  171.     mov    ax,2510h    ;DOS set vector function, vector 10h
  172.  
  173.     mov    dx,offset scroll_front_end    ;revector interrupt
  174.  
  175.     int    21h            ; 10h to front end routine
  176.  
  177.     mov    dx,offset endres ;# of paragraphs to make
  178.  
  179.     mov    cl,4        ; resident-can't do with an
  180.  
  181.     shr    dx,cl        ; expression because assembler can't
  182.  
  183.     inc    dx        ; calculate w/relocatable label
  184.  
  185.     mov    ax,3100h     ;DOS make resident fn, exit code=0
  186.  
  187.     int    21h        ;terminate & stay resident
  188.  
  189. start    endp
  190.  
  191. cseg    ends
  192.  
  193.     end    start
  194.  
  195.  
  196.  
  197.